package com.yyyit.bg2.run;

import java.util.concurrent.TimeUnit;

import com.yyyit.bg2.tools.ApiTest;
import com.yyyit.bg2.tools.tools;
import com.yyyit.bg2.pub.Login;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;

/**
 * @author lsjun
 *
 */
public final class CheckService {
	/**
	 * 
	 */
	private CheckService() {
		CheckService.main(null);
	}

	/**
	 * 使用log4j2,输出到数据库和控制台.
	 */
	private static Logger logger = LogManager.getLogger();

	/**
	 * 线程等待时间.
	 */
	public static final int WAITTIME = 3;

	/**
	 * 驱动等待超时时间.
	 */
	public static final int TIMEOUTS = 30;

	/**
	 * @author lsjun
	 * @param args
	 *            : none
	 */
	public static void main(final String[] args) {
		//WebDriver driver = new FirefoxDriver();
		// 更换环境时需要调整此处的链接和用户信息
		String baseUrl = "http://qaboss.qdingnet.com/";
		String userName = "admin", userPassword = "123456";
		logger.info(baseUrl);

		String model="brick";
		String[] URL={ baseUrl+"brick/app/data/building.json?cityId=3&projectId=62&timestamp=1426765893821&qdPlatform=android&qdDevice=mx4&qdVersion=1.1.2&sourceType=0"};
		//checkapis
		ApiTest.apisTest(model,URL);
		
		/*
		// 登录
		logger.info(Login.login(driver, baseUrl, userName, userPassword));

		tools.wait(WAITTIME);

		driver.get(baseUrl + "user");
		driver.manage().timeouts().implicitlyWait(TIMEOUTS, TimeUnit.SECONDS);
		driver.get(baseUrl + "brickadmin");
		driver.manage().timeouts().implicitlyWait(TIMEOUTS, TimeUnit.SECONDS);
		driver.get(baseUrl + "marketbg");
		driver.manage().timeouts().implicitlyWait(TIMEOUTS, TimeUnit.SECONDS);
		driver.get(baseUrl + "trade-webadmin");
		driver.manage().timeouts().implicitlyWait(TIMEOUTS, TimeUnit.SECONDS);
		driver.get(baseUrl + "hkbg");
		driver.manage().timeouts().implicitlyWait(TIMEOUTS, TimeUnit.SECONDS);
		driver.get(baseUrl + "ldbg/#/laundry/order");
		driver.getTitle();
		try {
			driver.findElement(By.linkText("详情"));
			logger.info("打开洗衣成功");
		} catch (Exception e) {
			logger.info("打开洗衣失败");

		}*/

		tools.wait(WAITTIME);
	//	driver.quit();
		logger.info("APIsTest做完了。");
	}
}
